home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / IPFlakeWay / Squelch Module / source / NatFTP.h < prev    next >
Text File  |  2000-06-23  |  3KB  |  71 lines

  1. // =================================================================================
  2. //    NatFTP.h                     ©1998 Sustainable Softworks. All rights reserved.
  3. // =================================================================================
  4. //    Network Address Translation for Embedded FTP Control channel
  5. //    This module translates the data portion of IP datagrams
  6. //    (technically a layering violation)
  7. //
  8. //    Since we must operate in the STREAMS context, this module is written
  9. //    in traditional C (not C++).
  10.  
  11. #ifndef _H_NatFTP
  12. #define _H_NatFTP
  13. #pragma once
  14.  
  15. #include "NatTable.h"
  16. #define nilp(type)        ((type*)0)
  17.  
  18. // ---------------------------------------------------------------------------
  19. //        • Convert2ApparentFtp
  20. // ---------------------------------------------------------------------------
  21. // Convert outgoing datagrams to appear as if they originate from
  22. // the apparent endpoint.  Return false if not a valid datagram or
  23. // no translation entry could be found or created.
  24. //
  25. // Handle embedded ftp control data
  26. // We assume there can only be one PORT command per segment!
  27. Boolean
  28. Convert2ApparentFtp(translationEntry_t table[],
  29.                     UInt8* datagram,
  30.                     mblk_t* mp,
  31.                     translationEntry_t* inLookupEntry,
  32.                     ip_header_t* ipHeader,
  33.                     tcp_header_t* tcpHeader);
  34.  
  35. // ---------------------------------------------------------------------------
  36. //        • Convert2ActualFtp
  37. // ---------------------------------------------------------------------------
  38. // Convert incomming datagram addressed to an apparent endpoint to
  39. // be forwarded to the corresponding actual endpoint.
  40. //
  41. // Handle embedded ftp control data
  42. // We assume there can only be one PORT command per segment!
  43. Boolean
  44. Convert2ActualFtp(translationEntry_t table[],
  45.                     UInt8* datagram,
  46.                     mblk_t* mp,
  47.                     translationEntry_t* inLookupEntry,
  48.                     ip_header_t* ipHeader,
  49.                     tcp_header_t* tcpHeader);
  50.  
  51.  
  52. // ---------------------------------------------------------------------------
  53. //        • DecodeFTPPort
  54. // ---------------------------------------------------------------------------
  55. //    Convert FTP "PORT n1,n2,n3,n4,n5,n6" command to address and protocol port
  56. //    Return length of PORT command, or Zero if command error detected
  57. UInt8
  58. DecodeFTPPort(UInt8* inStr, UInt16 inSize, UInt32* outAddr, UInt16* outPort);
  59.  
  60. // ---------------------------------------------------------------------------
  61. //        • EncodeFTPPort
  62. // ---------------------------------------------------------------------------
  63. //    Convert address and protocol port to FTP "PORT n1,n2,n3,n4,n5,n6\r\n" command
  64. //    Output as null terminated string.
  65. UInt8
  66. EncodeFTPPort(UInt32 inAddr, UInt16 inPort, char* outStr);
  67.  
  68. #define kFtpControlPort 21
  69. #define kFtpDataPort 20
  70.  
  71. #endif